package controllers;

import java.awt.event.ActionEvent;
import java.io.IOException;
import java.util.ArrayList;

import ccrm.BoundryControl;
import ccrm.ClientMain;
import entitys.Customer;
import entitys.Product;
import entitys.Request;
import entitys.Session;
import enums.Command;
import enums.Result;
import boundarys.AddClientGUI;

public class AddClientController {
	AddClientGUI acg;

	public AddClientController(AddClientGUI acg) {
		this.acg = acg;

	}

	/**
	 * Method for creating a request for server.
	 * Gets all CustomerID and all the id of categories chosen and sends request to server to add to DB.
	 */
	public static Result addClientCategories(ArrayList<String> custcategories) {
		
		Request r =new Request(Command.ADD_CLIENT_CATEGORIES,Session.getEmployee().getUserId(),custcategories);

		try {
			ClientMain.client.sendToServer(r);
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		return Result.OK;	

		
	}
	/**
	 * Method for creating a request for server.
	 * Gets all the fields needed for creating a customer and sends a request to server.
	 */
	public static Result addClient(String fname, String lname, String address,String phone,String email, String id, boolean permit, String birth)
	{
		Request r =new Request(Command.ADD_CLIENT,Session.getEmployee().getUserId(),new Customer(fname,lname,address,phone,email,id,permit,birth));

		try {
			ClientMain.client.sendToServer(r);
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		return Result.OK;	
	}

}